<template>
  <div>
    <el-form ref="dataForm" v-model="query" class="form" :rules="rules">
      <el-form-item prop="pbxURL">
        本地PBX代理 <el-input v-model="query.pbxURL" placeholder="请输入IP:Port" style="width: 400px;" />
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_1_5">
        <el-checkbox v-model="query.ck_007_sys_setting_1_5">所有渠道新建客户默认为未审核</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_1_15">
        <el-checkbox v-model="query.ck_007_sys_setting_1_15">押金审核时自动审核对应客户资料</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_1_22">
        <el-checkbox v-model="query.ck_007_sys_setting_1_22" title="总公司市价无需审核 第一级机构的管理员无需审核 数据权限为不限的无需审核">设置价格后需要上级审核（区域价、特别价）</el-checkbox>
      </el-form-item>
      <el-form-item prop="maxFloor" label="最高楼层:">
        <el-input-number v-model="query.maxFloor" size="mini" disabled controls-position="right" :min="0" />
      </el-form-item>
      <el-form-item prop="fee1" label="上楼费基数:">
        <el-input-number v-model="query.fee1" size="mini" disabled controls-position="right" :min="0" />
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_1_28">
        <el-checkbox v-model="query.ck_007_sys_setting_1_28">启用实名制订气</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_1_30">
        <el-checkbox v-model="query.ck_007_sys_setting_1_30">启用实名制开户</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_16">
        <el-checkbox v-model="query.ck_007_sys_setting_2_16">回收时间可修改</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_2_24">
        <el-checkbox v-model="query.ck_007_sys_setting_2_24">允许特价定义服务费</el-checkbox>
      </el-form-item>
      <el-form-item v-if="userInfo.userName === '007'" prop="ck_007_sys_setting_2_26">
        <el-checkbox v-model="query.ck_007_sys_setting_2_26">启用新版支付</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_3_8">
        <el-checkbox v-model="query.ck_007_sys_setting_3_8">兑换订单不允许退货</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_3_14">
        <el-checkbox v-model="query.ck_007_sys_setting_3_14">启用支付宝小程序</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_3_18">
        <el-checkbox v-model="query.ck_007_sys_setting_3_18">话务下单/微信审核时允许下达安检任务单</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_3_19">
        <el-checkbox v-model="query.ck_007_sys_setting_3_19">启用新版微信商城</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_3_10">
        <el-checkbox v-model="query.ck_007_sys_setting_3_10">客户地址归属机构随订单签收机构更新</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_3_31">
        <el-checkbox v-model="query.ck_007_sys_setting_3_31">安检不合格不再下发安检任务</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_sp4_1">
        <el-checkbox v-model="query.ck_007_sys_setting_sp4_1">随单安检自动审核</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_sp4_2">
        <el-checkbox v-model="query.ck_007_sys_setting_sp4_2">定期安检自动审核</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_5_12">
        <el-checkbox v-model="query.ck_007_sys_setting_5_12">开启电子合同签署</el-checkbox>
      </el-form-item>
      <el-form-item prop="ck_007_sys_setting_5_13">
        <el-checkbox v-model="query.ck_007_sys_setting_5_13">开启营业执照验证</el-checkbox>
      </el-form-item>
      <el-form-item prop="chipSupport" label="芯片识读支持">
        <el-select v-model="query.chipSupport" size="mini">
          <el-option :value="1" label="多立恒" />
          <el-option :value="2" label="华申" />
          <el-option :value="3" label="祥康" />
        </el-select>
      </el-form-item>
    </el-form>
    <table class="table" style="margin-left: 10px;" align="left">
      <thead align="center">
        <td>操作</td>
        <td>开启扫瓶</td>
        <td>启用异常校验</td>
        <td>开启库存校验</td>
      </thead>
      <tbody align="center">
        <tr>
          <td>配送领瓶</td>
          <td>
            <el-checkbox :checked="true" disabled />
          </td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_0" />
          </td>
          <td>--</td>
        </tr>
        <tr>
          <td>配送</td>
          <td>
            <el-checkbox :checked="true" disabled />
          </td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_1" />
          </td>
          <td>--</td>
        </tr>
        <tr>
          <td>配送还瓶</td>
          <td>
            <el-checkbox :checked="true" disabled />
          </td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_2" />
          </td>
          <td>--</td>
        </tr>
        <tr>
          <td>欠瓶还瓶</td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_3" />
          </td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_4" />
          </td>
          <td>--</td>
        </tr>
        <tr>
          <td>退瓶</td>
          <td>
            <el-checkbox :checked="true" disabled />
          </td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_5" />
          </td>
          <td>--</td>
        </tr>
        <tr>
          <td>回收商品扫瓶</td>
          <td rowspan="2">
            <el-checkbox v-model="query.ck_007_sys_setting_5_6" />
          </td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_7" />
          </td>
          <td>--</td>
        </tr>
        <tr>
          <td>置换商品扫瓶</td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_8" />
          </td>
          <td>--</td>
        </tr>
        <tr>
          <td>装车扫瓶</td>
          <td rowspan="2">
            <el-checkbox v-model="query.ck_007_sys_setting_5_9" />
          </td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_10" />
          </td>
          <td rowspan="2">
            <el-checkbox v-model="query.ck_007_sys_setting_5_14" />
          </td>
        </tr>
        <tr>
          <td>卸车扫瓶</td>
          <td>
            <el-checkbox v-model="query.ck_007_sys_setting_5_11" />
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
  import { mapGetters } from 'vuex'

  export default {
    name: 'BasicTab',
    data() {
      return {
        query: {
          pbxURL: '',
          maxFloor: '',
          sp1: false,
          fee1: '',
          chipSupport: 1,
          ck_007_sys_setting_1_5: false,
          ck_007_sys_setting_1_15: false,
          ck_007_sys_setting_1_22: false,
          ck_007_sys_setting_1_28: false,
          ck_007_sys_setting_1_30: false,
          ck_007_sys_setting_2_16: false,
          ck_007_sys_setting_2_24: false,
          ck_007_sys_setting_2_26: false,
          ck_007_sys_setting_3_8: false,
          ck_007_sys_setting_3_14: false,
          ck_007_sys_setting_3_18: false,
          ck_007_sys_setting_3_19: false,
          ck_007_sys_setting_3_10: false,
          ck_007_sys_setting_3_31: false,
          ck_007_sys_setting_sp4_1: false,
          ck_007_sys_setting_sp4_2: false,
          ck_007_sys_setting_5_12: false,
          ck_007_sys_setting_5_13: false,
          ck_007_sys_setting_5_0: false,
          ck_007_sys_setting_5_1: false,
          ck_007_sys_setting_5_2: false,
          ck_007_sys_setting_5_3: false,
          ck_007_sys_setting_5_4: false,
          ck_007_sys_setting_5_5: false,
          ck_007_sys_setting_5_6: false,
          ck_007_sys_setting_5_7: false,
          ck_007_sys_setting_5_8: false,
          ck_007_sys_setting_5_9: false,
          ck_007_sys_setting_5_10: false,
          ck_007_sys_setting_5_14: false,
          ck_007_sys_setting_5_11: false
        },
        rules: {
          // pbxURL: [{ required: true, message: '请输入', trigger: 'change' }]
        }
      }
    },
    computed: {
      ...mapGetters([
        'corpSettingData', 'userInfo'
      ])
    },
    created() {
      this.init()
    },
    methods: {
      init() {
        if (this.corpSettingData) {
          this.query.pbxURL = this.corpSettingData.pbxURL
          this.query.ck_007_sys_setting_1_5 = !!(this.corpSettingData.sp1 >> 5 & 0x01)
          this.query.ck_007_sys_setting_1_1 = !!(this.corpSettingData.sp1 >> 1 & 0x01)
          this.query.ck_007_sys_setting_1_15 = !!(this.corpSettingData.sp1 >> 15 & 0x01)
          this.query.ck_007_sys_setting_1_22 = !!(this.corpSettingData.sp1 >> 22 & 0x01)
          this.query.ck_007_sys_setting_1_28 = !!(this.corpSettingData.sp1 >> 28 & 0x01)
          this.query.ck_007_sys_setting_1_30 = !!(this.corpSettingData.sp1 >> 30 & 0x01)
          this.query.ck_007_sys_setting_2_16 = !!(this.corpSettingData.sp2 >> 16 & 0x01)
          this.query.ck_007_sys_setting_2_24 = !!(this.corpSettingData.sp2 >> 24 & 0x01)
          this.query.ck_007_sys_setting_2_26 = !!(this.corpSettingData.sp2 >> 26 & 0x01)
          this.query.ck_007_sys_setting_3_8 = !!(this.corpSettingData.sp3 >> 8 & 0x01)
          this.query.ck_007_sys_setting_3_14 = !!(this.corpSettingData.sp3 >> 14 & 0x01)
          this.query.ck_007_sys_setting_3_18 = !!(this.corpSettingData.sp3 >> 18 & 0x01)
          this.query.ck_007_sys_setting_3_19 = !!(this.corpSettingData.sp3 >> 19 & 0x01)
          this.query.ck_007_sys_setting_3_10 = !!(this.corpSettingData.sp3 >> 10 & 0x01)
          this.query.ck_007_sys_setting_3_31 = !!(this.corpSettingData.sp3 >> 31 & 0x01)
          this.query.ck_007_sys_setting_sp4_1 = !!(this.corpSettingData.sp4 >> 1 & 0x01)
          this.query.ck_007_sys_setting_sp4_2 = !!(this.corpSettingData.sp4 >> 2 & 0x01)
          this.query.ck_007_sys_setting_5_12 = !!(this.corpSettingData.sp5 >> 12 & 0x01)
          this.query.ck_007_sys_setting_5_13 = !!(this.corpSettingData.sp5 >> 13 & 0x01)
          this.query.ck_007_sys_setting_5_0 = !!(this.corpSettingData.sp5 & 0x01)
          this.query.ck_007_sys_setting_5_1 = !!(this.corpSettingData.sp5 >> 1 & 0x01)
          this.query.ck_007_sys_setting_5_2 = !!(this.corpSettingData.sp5 >> 2 & 0x01)
          this.query.ck_007_sys_setting_5_3 = !!(this.corpSettingData.sp5 >> 3 & 0x01)
          this.query.ck_007_sys_setting_5_4 = !!(this.corpSettingData.sp5 >> 4 & 0x01)
          this.query.ck_007_sys_setting_5_5 = !!(this.corpSettingData.sp5 >> 5 & 0x01)
          this.query.ck_007_sys_setting_5_6 = !!(this.corpSettingData.sp5 >> 6 & 0x01)
          this.query.ck_007_sys_setting_5_7 = !!(this.corpSettingData.sp5 >> 7 & 0x01)
          this.query.ck_007_sys_setting_5_8 = !!(this.corpSettingData.sp5 >> 8 & 0x01)
          this.query.ck_007_sys_setting_5_9 = !!(this.corpSettingData.sp5 >> 9 & 0x01)
          this.query.ck_007_sys_setting_5_10 = !!(this.corpSettingData.sp5 >> 10 & 0x01)
          this.query.ck_007_sys_setting_5_14 = !!(this.corpSettingData.sp5 >> 14 & 0x01)
          this.query.ck_007_sys_setting_5_11 = !!(this.corpSettingData.sp5 >> 11 & 0x01)
          this.query.fee1 = this.corpSettingData.fee1 * 0.01
          // 芯片识读支持设置
          if ((this.corpSettingData.sp4 >> 22 & 0x01) > 0) {
            this.query.sp4 = 2
          }
          if ((this.corpSettingData.sp4 >> 23 & 0x01) > 0) {
            this.query.sp4 = 3
          }
        }
      }
    }
  }
</script>

<style lang="scss" scoped>
.form {
  .el-form-item {
    margin-bottom: 0;
  }
}
.table {
  border-collapse: collapse;
  td {
    padding: 5px 10px;
    border: 1px solid #dedede;
  }
}
</style>
